package com.ruoyi.electronicFence.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.electronicFence.domain.TAlgorithmResult;
import com.ruoyi.electronicFence.service.ITAlgorithmResultService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 算法结果Controller
 *
 * @author sxygsj
 * @date 2024-07-12
 */
@RestController
@RequestMapping("/electronicFence/result")
public class TAlgorithmResultController extends BaseController
{
    @Autowired
    private ITAlgorithmResultService tAlgorithmResultService;

    /**
     * 查询算法结果列表
     */
    //@PreAuthorize("@ss.hasPermi('electronicFence:result:list')")
    @GetMapping("/list")
    public TableDataInfo list(TAlgorithmResult tAlgorithmResult)
    {
        startPage();
        List<TAlgorithmResult> list = tAlgorithmResultService.selectTAlgorithmResultList(tAlgorithmResult);
        return getDataTable(list);
    }

    /**
     * 导出算法结果列表
     */
    //@PreAuthorize("@ss.hasPermi('electronicFence:result:export')")
    @Log(title = "算法结果", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TAlgorithmResult tAlgorithmResult)
    {
        List<TAlgorithmResult> list = tAlgorithmResultService.selectTAlgorithmResultList(tAlgorithmResult);
        ExcelUtil<TAlgorithmResult> util = new ExcelUtil<TAlgorithmResult>(TAlgorithmResult.class);
        util.exportExcel(response, list, "算法结果数据");
    }

    /**
     * 获取算法结果详细信息
     */
    //@PreAuthorize("@ss.hasPermi('electronicFence:result:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tAlgorithmResultService.selectTAlgorithmResultById(id));
    }

    /**
     * 新增算法结果
     */
    //@PreAuthorize("@ss.hasPermi('electronicFence:result:add')")
    @Log(title = "算法结果", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TAlgorithmResult tAlgorithmResult)
    {
        return toAjax(tAlgorithmResultService.insertTAlgorithmResult(tAlgorithmResult));
    }

    /**
     * 修改算法结果
     */
    //@PreAuthorize("@ss.hasPermi('electronicFence:result:edit')")
    @Log(title = "算法结果", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TAlgorithmResult tAlgorithmResult)
    {
        return toAjax(tAlgorithmResultService.updateTAlgorithmResult(tAlgorithmResult));
    }

    /**
     * 删除算法结果
     */
    //@PreAuthorize("@ss.hasPermi('electronicFence:result:remove')")
    @Log(title = "算法结果", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tAlgorithmResultService.deleteTAlgorithmResultByIds(ids));
    }
}
